package ui.panels.strategies;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;

import ui.flowManager.FlowManagerImpl;

public class StrategyFrame extends JFrame{

	private String name;
	
	public StrategyFrame(String name)
	{
		super();
		this.name = name;
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        this.setSize(400,325);
        this.setResizable(false);
        //This will center the JFrame in the middle of the screen
        this.setLocationRelativeTo(null);
        this.setVisible(true);
        
        //disable the the primary GUI
        FlowManagerImpl.getInstance().setEnable(false);
        
        //set listener to close
        this.addWindowListener(new WindowEventHandler());
        
        
	}
	
	/**
	 * @author vladimir && alon
	 *	When the Frame is closed enable the prime GUI
	 */
	private class WindowEventHandler extends WindowAdapter {
		  public void windowClosing(WindowEvent evt) { 
		    //set enable the primary GUI
			 FlowManagerImpl.getInstance().setEnable(true);
		  }
	}
	
}
